package org.yoome.jtools.distributelock;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;


public class LockConfiguration {

    @Autowired
    DistributedLock distributedLock;

    private Integer order;

    @Bean
    public LockPointCutBeanFactoryAdvisor getAdvisor() {
        LockPointCutBeanFactoryAdvisor advisor = new LockPointCutBeanFactoryAdvisor();
        advisor.setAdvice(new LockMethodInterceptor(distributedLock));
//        if (Objects.nonNull(order)) {
//            advisor.setOrder(order);
//        }
        return advisor;
    }

    public Integer getOrder() {
        return order;
    }

    public void setOrder(Integer order) {
        this.order = order;
    }
}
